package io.renren.modules.hos.service.impl;

import io.renren.modules.hos.service.DoctorService;
import io.renren.modules.hos.vo.DoctorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.hos.dao.DepartmentDao;
import io.renren.modules.hos.entity.DepartmentEntity;
import io.renren.modules.hos.service.DepartmentService;


@Service("departmentService")
public class DepartmentServiceImpl extends ServiceImpl<DepartmentDao, DepartmentEntity> implements DepartmentService {
    @Autowired
    private DoctorService doctorService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<DepartmentEntity> page = this.page(
                new Query<DepartmentEntity>().getPage(params),
                new QueryWrapper<DepartmentEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<DoctorVo> selectDoctorByDep(Long depId) {
        DepartmentEntity departmentEntity = this.getById(depId);

        return doctorService.selectDoctorByDep(departmentEntity.getDepartmentName());
    }

}